package com.daodai.hjcjsystem.task;

import com.daodai.hjcjsystem.service.CollectionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务类，每天凌晨备份上一天的数据为一张数据库表
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class ScheduleTask {

    private final CollectionService collectionService;


    @Scheduled(cron = "0 10 * * * ? ")//每天的凌晨0点10分执行
    public void scheduleSave(){
        collectionService.backup();
    }

    /**
     * 定时删除device_realtime_value表中数据
     */

    @Scheduled(cron = "0 0 12 * * ? ")//每天的中午十二点执行
    public void deleteTask(){
        collectionService.deleteTask();

    }

}
